/**
 * 文件名：LogisticsVehicleService.java
 *
 * 创建人：Fyh - 1009173473@qq.com
 *
 * 创建时间：2019年9月25日 下午5:15:56
 *
 * 版权所有：南京植百汇智能科技服务有限公司
 */
package com.z100h.supplychain.evidence.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.z100h.supplychain.core.VehicleState;
import com.z100h.supplychain.evidence.entity.LogisticsVehicle;
import com.z100h.supplychain.evidence.entity.LogisticsVehicleListVo;
import com.z100h.supplychain.evidence.entity.Worker;
import com.z100h.supplychain.evidence.mapper.LogisticsVehicleMapper;

/**
 * [描述信息：说明类的基本功能]
 *
 * @author Fyh - 1009173473@qq.com
 * @version 1.0 Created on 2019年9月25日 下午5:15:56
 */
@Service
public class LogisticsVehicleService extends CrudService<LogisticsVehicleMapper, LogisticsVehicle> {

	@Autowired
	private LogisticsVehicleMapper logisticsVehicleMapper;

	public Page<LogisticsVehicle> findByPage(Page<LogisticsVehicle> page, LogisticsVehicle logisticsVehicle) {
		dataRuleFilter(logisticsVehicle);
		logisticsVehicle.preInsert();
		logisticsVehicle.setPage(page);
		page.setList(logisticsVehicleMapper.findByPage(logisticsVehicle));
		return page;
	}

	public List<LogisticsVehicleListVo> findByLogisticsVehicleList() {
		return logisticsVehicleMapper.findByLogisticsVehicleList(UserUtils.getUser().getCompanyId());
	}

	public void insert(LogisticsVehicle logisticsVehicle) {
		logisticsVehicle.preInsert();
		logisticsVehicle.setState(VehicleState.NOTLOAD.getType());
		logisticsVehicleMapper.insertLogisticsVehicle(logisticsVehicle);
	}

	public Page<LogisticsVehicle> findLoadByPage(Page<LogisticsVehicle> page, LogisticsVehicle logisticsVehicle) {
		dataRuleFilter(logisticsVehicle);
		logisticsVehicle.preInsert();
		logisticsVehicle.setPage(page);
		page.setList(logisticsVehicleMapper.findLoadByPage(logisticsVehicle));
		return page;
	}

	public void finish(List<String> ids, String state, String finishOp) {
		logisticsVehicleMapper.finish(ids, state, finishOp);
	}

	public void updateRepairAssign(String uid, String workDate, List<String> repairIds) {
		logisticsVehicleMapper.updateRepairAssign(uid, workDate, repairIds);
	}

	public List<Worker> findWorkerListByPostType(String postType) {
		return logisticsVehicleMapper.findWorkerListByPostType(postType);
	}

	public List<String> findCustomerIdsByIds(List<String> ids) {
		return logisticsVehicleMapper.findCustomerIdsByIds(ids);
	}

}
